﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business.Util;
using ZLCMS.Business.TranferParam;
using DotNet.Common.TransferParam;

namespace ZLCMS.Web.Example
{
    public partial class ParamDisplay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = ParamKit.GetInstance().Count.ToString();

            ParamKit.Bind("City", DropDownList1, null, null, null, "-1", null);

            ParamKit.Bind("City", RadioButtonList1, null, null, null, "SG", null);

            ParamKit.Bind("City", CheckBoxList1, null, null, null, "SG", null);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ParamKit.GetInstance();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            ParamKit.GetInstance().Fresh();
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            ParamKit.GetInstance().Fresh(TextBox1.Text);
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            Label2.Text = ParamKit.GetValue(TextBox2.Text, TextBox3.Text, null);
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            Label3.Text = ParamKit.GetParam(TextBox4.Text, TextBox5.Text, TextBox6.Text, TextBox7.Text);
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            Repeater1.DataSource = ParamKit.GetValueList(TextBox8.Text, null);
            Repeater1.DataBind();
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            List<ParamFilterCondition> list = new List<ParamFilterCondition>();

            if (TextBox10.Text != "")
            {
                list.Add(new ParamFilterCondition { Code = TextBox10.Text, Value = TextBox11.Text });
            }

            if (TextBox12.Text != "")
            {
                list.Add(new ParamFilterCondition { Code = TextBox12.Text, Value = TextBox13.Text });
            }

            Repeater2.DataSource = ParamKit.GetValueList(TextBox9.Text, list);
            Repeater2.DataBind();
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            List<ParamFilterCondition> list = new List<ParamFilterCondition>();

            if (TextBox15.Text != "")
            {
                list.Add(new ParamFilterCondition { Code = TextBox15.Text, Value = TextBox16.Text });
            }

            if (TextBox17.Text != "")
            {
                list.Add(new ParamFilterCondition { Code = TextBox17.Text, Value = TextBox18.Text });
            }

            Repeater3.DataSource = ParamKit.GetParamList(TextBox14.Text, TextBox19.Text, list);
            Repeater3.DataBind();
        }
    }
}
